package com.vancouver.knows.business;

import android.os.Message;

import com.pangu.AMApplication;
import com.pangu.AModule;
import com.pangu.bean.ContextConfig;
import com.vancouver.knows.business.cache.CacheManager;
import com.vancouver.knows.business.task.BServiceWrapper;
import com.vancouver.knows.business.task.BTaskMarkPool;

/**
 * Created by chenxunlin01 on 2015/11/23.
 */
public class BusinessModule extends AModule {

    public static final String TAG = BusinessModule.class.getSimpleName();

    private BeanManager beanManager;

    public BusinessModule(AMApplication context, String moduleMark) {
        super(context, moduleMark);
    }

    @Override
    public void initForLongLive() {
        try {
            // 清除任务状态
            getTaskMarkPool().reinitForLongLive();
            //清楚缓存
            getCacheManager().clearCache();

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    protected void doInitContext() throws Exception {

    }

    @Override
    protected void doBuildModule() throws Exception {

    }

    @Override
    protected void doInitModule() throws Exception {
        beanManager = new BeanManager(this);
    }

    @Override
    public String TAG() {
        return TAG;
    }

    @Override
    public BTaskMarkPool getTaskMarkPool() {
        return beanManager.getTaskMarkPool();
    }

    @Override
    public BServiceWrapper getServiceWrapper() {
        return beanManager.getServiceWrapper();
    }

    public CacheManager getCacheManager() {
        return beanManager.getCacheManager();
    }

    @Override
    protected void subHandleMessage(Message msg) {

    }

    public AMApplication getAMApplication() {
        return mContext;
    }
    

    /**
     * 获取环境配置
     *
     * @return
     */
    public ContextConfig getContextConfig() {
        return mContext.getContextConfig();
    }
}
